<template>
	<view>
		<view style="margin-bottom: 30rpx;">
			<v-tabs :fixed="true" :zIndex='9' :scroll="false" color="#333333" activeColor="#CF1A09" lineHeight="5rpx"
				lineColor="#CF1A09" v-model="current" :tabs="tabs" @change="changeTab"></v-tabs>
		</view>

		<navigator :url="'/pages/suggest/detail?id='+item.id+'&type=3'" hover-class="none" class="list" v-for="(item,index) in list"
			:key="index">
			<view class="list-name">{{item.title}}</view>
			<view class="flex align between time">
				<view style="color: #8A8A8A;font-size: 18rpx;">{{item.create_time}}</view>
				<view class="status">{{item.status_text}}</view>
				<!-- <view class="status status2" v-if="item.status==2">{{item.status_text}}</view> -->
			</view>
		</navigator>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
	</view>
</template>

<script>
	import {
		problemListAd
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				current: 0,
				tabs: ['待审核', '已通过','未通过','处理中','已反馈'],
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
			};
		},
		onLoad() {
			this.getlist();
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			changeTab(index) {
				const that = this;
				that.current = index
				this.page = 0
				this.list = []
				this.getlist();
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					current
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
					status: current + 1
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await problemListAd(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							console.log((888))
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		background: white;
		padding: 16rpx 24rpx;
		margin-bottom: 20rpx;

		.list-name {
			font-size: 24rpx;
			font-weight: bold;
		}

		.time {
			margin-top: 19rpx;
		}

		.status {
			background: #FFCF7D;
			width: 86rpx;
			line-height: 41rpx;
			border-radius: 4rpx;
			color: #E38F00;
			font-size: 18rpx;
			text-align: center;
		}
	}
</style>